package com.key.w8.http1.connection.environment;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.concurrent.TimeUnit;

/**
 * @Author: k8
 * @CreateTime: 2025-02-18
 * @Version: 1.0
 */
@Data
public abstract class Http1Environment<E extends Http1Environment<E>> extends ConnectionEnvironment{

    // 默认常量值
    public static final int DEFAULT_MAX_REQUEST_SIZE = 8192;  // 默认最大请求体大小（8KB）
    public static final int DEFAULT_MAX_CONTENT_SIZE = 8192;   // 默认最大content大小,写入的请求或响应
    public static final int DEFAULT_MAX_HEADER_SIZE = 8192;   // 默认最大请求头大小（8KB）

    public static final long DEFAULT_READ_TIMEOUT = 30000;       // 默认读取超时时间（30秒）
    public static final long DEFAULT_WRITE_TIMEOUT = 30000;      // 默认写入超时时间（30秒）
    public static final long DEFAULT_RESPONSE_TIMEOUT = 30000;      // 默认响应超时时间（30秒）

    private boolean compressResponseContent = false;
    private int maxContentLength = DEFAULT_MAX_CONTENT_SIZE;

    // 配置参数
    private int maxRequestSize = DEFAULT_MAX_REQUEST_SIZE;    // 最大请求体大小
    private int maxHeaderSize = DEFAULT_MAX_HEADER_SIZE;      // 最大请求头大小

    private long readTimeout = DEFAULT_READ_TIMEOUT;           // 读取超时时间
    private long writeTimeout = DEFAULT_WRITE_TIMEOUT;         // 写入超时时间

    private long responseTimeOut = DEFAULT_RESPONSE_TIMEOUT;

    protected abstract E self();

    public boolean isCompressResponseContent() {
        return compressResponseContent;
    }

    public Http1Environment(boolean isServer) {
        super(isServer);
    }
}

